﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SupplyChainManagement
{
    public class Subject
    {
        public delegate void NotifyObserver(string id, InventoryDetail form);
        public NotifyObserver DataChanged;

        public Subject(string id)
        {
            this.DataChanged += new NotifyObserver(Notify);
        }

        public void Update(string id, InventoryDetail form)
        {
            OnNotify(id, form);
        }

        private void OnNotify(string id, InventoryDetail form)
        {
            if (DataChanged != null)
                DataChanged(id, form);
        }

        private void Notify(string id, InventoryDetail form)
        {
            Observer obs = new Observer(id, form);
            obs.Update(id);
        }
    }
}
